﻿@model NextAction.WebUI.Models.GtdTaskIndexViewModel

@{
    Layout = null;

    var updateTargetName = "data_" + Model.TaskType.ToString();

    var newTaskInput = "new_task_" + Model.TaskType.ToString();

    var newTaskOnSuccess = "OnSuccess_" + Model.TaskType.ToString();
    
    AjaxOptions ajaxOpts = new AjaxOptions
    {
        UpdateTargetId = updateTargetName,
        Url = Url.Action("GtdTaskListData", new { Model.TaskType }),
        OnSuccess = newTaskOnSuccess
    };
}

    <script type="text/javascript">
        function @newTaskOnSuccess (data) {
            $('#@newTaskInput').val("");
        }
    </script>


@using (Ajax.BeginForm("GtdTaskListData", ajaxOpts))
{
    <div class="post" id="post-28">

	    <div class="post_title_left">
	    <div class="post_title_right post_title_body">
		    <h1 class="left">
                @Model.TaskType.ToString()
            </h1>
            <div class="right">
                <span class="comment">
                    @Html.ActionLink("Add", "Create", "Task", new { Model.TaskType }, null)
                </span>
            </div>
		    <div class="clearer">&nbsp;</div>
        </div>
        </div>

	    <div class="post_body">
			    <table class="search">
			    <tr>
                    @Html.TextBox("newTaskName", "", new { Class = "text-box", ID = newTaskInput })
			    </tr>
			    </table>
	    </div>

	    <div class="post_bottom"></div>

    </div>

    <div class="post" id="comments">
					
        <div class="post_title_left">
	    <div class="post_title_right post_title_body">

		    <h1 class="left"></h1>
            <div class="post_date right">@Model.GtdTasks.Count() task(s)</div>
		    <div class="clearer">&nbsp;</div>
	    </div>
        </div>

        <div class="post_body nicelist">
	            <ol id= "@updateTargetName" >
                    @Html.Action("GtdTaskListData", new { Model.TaskType })
                </ol>
	    </div>
    </div>

}
        

